package com.ruoyi.business.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.JtExpressDeliveryCompany;
import com.ruoyi.business.service.IJtExpressDeliveryCompanyService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 快递物流公司Controller
 * 
 * @author Alan Zhang
 * @date 2025-06-11
 */
@Controller
@RequestMapping("/business/express")
public class JtExpressDeliveryCompanyController extends BaseController
{
    private String prefix = "business/express";

    @Autowired
    private IJtExpressDeliveryCompanyService jtExpressDeliveryCompanyService;

    @RequiresPermissions("business:express:view")
    @GetMapping()
    public String express()
    {
        return prefix + "/express";
    }

    /**
     * 查询快递物流公司列表
     */
    @RequiresPermissions("business:express:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(JtExpressDeliveryCompany jtExpressDeliveryCompany)
    {
        startPage();
        List<JtExpressDeliveryCompany> list = jtExpressDeliveryCompanyService.selectJtExpressDeliveryCompanyList(jtExpressDeliveryCompany);
        return getDataTable(list);
    }

    /**
     * 导出快递物流公司列表
     */
    @RequiresPermissions("business:express:export")
    @Log(title = "快递物流公司", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JtExpressDeliveryCompany jtExpressDeliveryCompany)
    {
        List<JtExpressDeliveryCompany> list = jtExpressDeliveryCompanyService.selectJtExpressDeliveryCompanyList(jtExpressDeliveryCompany);
        ExcelUtil<JtExpressDeliveryCompany> util = new ExcelUtil<JtExpressDeliveryCompany>(JtExpressDeliveryCompany.class);
        return util.exportExcel(list, "快递物流公司数据");
    }

    /**
     * 新增快递物流公司
     */
    @RequiresPermissions("business:express:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存快递物流公司
     */
    @RequiresPermissions("business:express:add")
    @Log(title = "快递物流公司", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(JtExpressDeliveryCompany jtExpressDeliveryCompany)
    {
        return toAjax(jtExpressDeliveryCompanyService.insertJtExpressDeliveryCompany(jtExpressDeliveryCompany));
    }

    /**
     * 修改快递物流公司
     */
    @RequiresPermissions("business:express:edit")
    @GetMapping("/edit/{expressId}")
    public String edit(@PathVariable("expressId") Long expressId, ModelMap mmap)
    {
        JtExpressDeliveryCompany jtExpressDeliveryCompany = jtExpressDeliveryCompanyService.selectJtExpressDeliveryCompanyByExpressId(expressId);
        mmap.put("jtExpressDeliveryCompany", jtExpressDeliveryCompany);
        return prefix + "/edit";
    }

    /**
     * 修改保存快递物流公司
     */
    @RequiresPermissions("business:express:edit")
    @Log(title = "快递物流公司", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(JtExpressDeliveryCompany jtExpressDeliveryCompany)
    {
        return toAjax(jtExpressDeliveryCompanyService.updateJtExpressDeliveryCompany(jtExpressDeliveryCompany));
    }

    /**
     * 删除快递物流公司
     */
    @RequiresPermissions("business:express:remove")
    @Log(title = "快递物流公司", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(jtExpressDeliveryCompanyService.deleteJtExpressDeliveryCompanyByExpressIds(ids));
    }
}
